package common;

import java.text.MessageFormat;

/**
 * A basic triplet object
 * 
 * @author Gal Lalouche
 * @param <First> The first type
 * @param <Second> The second type
 * @param <Third> Third type
 */
public class Triple<First, Second, Third> {
	/**
	 * The first object in the triple
	 */
	public final First	first;
	/**
	 * The second object in the triple
	 */
	public final Second	second;
	
	/**
	 * Third element in the triple
	 */
	public final Third	third;
	
	/**
	 * Creates a new pair
	 * 
	 * @param first The first object
	 * @param second The second object
	 * @param third The third object
	 */
	public Triple(First first, Second second, Third third) {
		super();
		this.first = first;
		this.second = second;
		this.third = third;
	}
	
	/**
	 * Creates a new pair from the types. <br>
	 * syntactic sugar of the constructor
	 * 
	 * @param <First> The type of the first object
	 * @param <Second> The type of the second object
	 * @param <Third> The type of the third object
	 * @param first The first object
	 * @param second The second object
	 * @param third The third object
	 * @return A new triplet made of the arguments
	 */
	public static <First, Second, Third> Triple<First, Second, Third> of(First first, Second second, Third third) {
		return new Triple<>(first, second, third);
	}
	
	@Override
	public String toString() {
		return MessageFormat.format("[{0}, {1}, {2}]", first, second, third);
	}
}
